package cn.seaboot.admin.excel.manager;

import cn.seaboot.admin.file.resource.ClassPathResourceProperties;
import cn.seaboot.admin.file.resource.ClassPathResourceService;
import cn.seaboot.commons.file.MimeUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;

/**
 * Excel模版操作
 * <p>
 *
 * @author ChenSS
 * @version 2019-04-22 15:26:05
 */
@Service
public class ExcelTemplateService {

    @Resource
    private ClassPathResourceService classPathResourceService;

    @Resource
    private ClassPathResourceProperties classPathResourceProperties;

    /**
     * 打开模版文件的输入流
     *
     * @param tplName 模版名称，不包括后缀，例如：user
     * @throws IOException -
     */
    public InputStream openInputStream(String tplName) throws IOException {
        return classPathResourceService.openInputSteam(classPathResourceProperties.getExcel(), tplName, MimeUtils.XLSX);
    }
}